//
// Created by 刘禹晨 on 5/19/16.
// Copyright (c) 2016 刘禹晨. All rights reserved.
//

#import "ZigbeeModel.h"


@implementation ZigbeeModel

-(id)init
{
    if(self=[super init])
    {
        _childrenList = [NSMutableArray array];
        _nodeDict = [NSMutableDictionary dictionary];
        _isArm = @"";
    }
    return self;
}

-(void)createDictionary
{
    
    [_nodeDict setValue:self.NodeMac forKey:@"address"];
    if([self.NodeType isEqualToString:@"E"]) {
        [_nodeDict setValue:@"end" forKey:@"nodetype"];
    }else if([self.NodeType isEqualToString:@"R"])
    {
        [_nodeDict setValue:@"router" forKey:@"nodetype"];
    } else{
        [_nodeDict setValue:@"coordinator" forKey:@"nodetype"];
    }
    if([self.isArm isEqualToString:@"N"] && [self.AlterState isEqualToString:@"R"]){
        [_nodeDict setObject:@"DisArming" forKey:@"state"];
    }else if([self.isArm isEqualToString:@"S"] && [self.AlterState isEqualToString:@"R"]){
        [_nodeDict setObject:@"Arming" forKey:@"state"];
    }else if([self.AlterState isEqualToString:@"A"]){
       [_nodeDict setObject:@"Alarm" forKey:@"state"];
    }else{
        [_nodeDict setObject:@"Normal" forKey:@"state"];
    }
    //[_nodeDict setValue:self.ParentNetworkAddress forKey:@"parentAddress"];
    [_nodeDict setObject:self.childrenList forKey:@"children"];
}

-(void)clearDictonary
{
    [self.nodeDict removeAllObjects];
    [self.childrenList removeAllObjects];
}



@end